package com.lvyq.myplayer.presenter.impl

import com.lvyq.myplayer.base.BaseListPresenter
import com.lvyq.myplayer.base.BaseView
import com.lvyq.myplayer.model.area.MvPagerBean
import com.lvyq.myplayer.net.ResponseHandler
import com.lvyq.myplayer.net.home.MvListRequest
import com.lvyq.myplayer.presenter.inter.MvListPresenter
import com.lvyq.myplayer.view.MvListView

/**
 * 文件描述：MvListPresenterImpl
 * 作者：lvyq
 * 创建时间：2025-02-26
 * 修改时间：2025-02-26
 */
class MvListPresenterImpl(var code:String ,var mvListView: BaseView<MvPagerBean>): MvListPresenter,
    ResponseHandler<MvPagerBean> {
    override fun loadMore(pageNum: Int) {
        MvListRequest(BaseListPresenter.TYPE_LOAD_MORE,code,pageNum,this).excute()

    }

    override fun loadDatas() {
        MvListRequest(BaseListPresenter.TYPE_INIT,code,1,this).excute()
    }

    override fun destoryView() {
    }

    override fun onError(type: Int, msg: String) {
        mvListView.onError(msg)
    }

    override fun onSuccess(type: Int, result: MvPagerBean) {
        when(type){
            BaseListPresenter.TYPE_INIT ->mvListView.loadSuccess(result,result.total)
            BaseListPresenter.TYPE_LOAD_MORE ->mvListView.loadMore(result,result.total)
        }
    }


}